package com.gzmu.storage.mapper;

import com.gzmu.storage.entity.Cabinet;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xiaobo Yan
 * @since 2020-04-16
 */
@Mapper
public interface CabinetMapper extends BaseMapper<Cabinet> {
    @Insert("INSERT INTO t_cabinet(stationid,name,serial,status,createtime,updatetime,remark) VALUES(#{stationid}," +
            "#{name},#{serial},#{status},now(),now(),#{remark}) ON DUPLICATE KEY UPDATE stationid=#{stationid}," +
            "name=#{name},serial=#{serial},status=#{status},updatetime=now(),remark=#{remark}")
    @Options(useGeneratedKeys = true)
    boolean insertAndUpdate(Cabinet cabinet);

    @Update( "UPDATE t_cabinet SET status=#{status} WHERE id=#{id}" )
    boolean updateCabinetStatus(@Param( "id" ) Integer id, @Param( "status" ) Integer status);
}
